<%@include file="/WEB-INF/views/includes/taglibs.jsp"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@include file="/WEB-INF/views/includes/adminHeader.jsp"%>



<!--[if gte IE 6]>
<script>
$(document).ready( function() {
$(".dataRow").mouseover(function(){$(this).addClass("dataRowOver");});
$(".dataRow").mouseout(function(){$(this).removeClass("dataRowOver");});
});
</script>
<![endif]-->
<script type="text/javascript">
function editConnection(id) {
	window.location.href = "<c:url value='/web/editFunction?id='/>" + id;
}
function addNewSystem() {
	$('#newConnectorConfigDialog').dialog('open');
}
function deleteConfiguration(id, name) {
	$("#deleteId").val(id);
	$("#deleteName").text(name);
	$('#deleteDialog').dialog('open');
}
$(document).ready(
		function() {
			$('#newConnectorConfigDialog').dialog({
				autoOpen: false,
				width: 500,
				draggable : true,
				resizable : false,
				dialogClass : 'commonDialog',
				buttons: {
					"Ok": function() {
						$('#newConnectorConfigform').submit();
					},
					"Cancel": function() {
						$(this).dialog("close");
					}
				}
			});
			
			$('#deleteDialog').dialog({
				autoOpen: false,
				width: 400,
				draggable : true,
				resizable : false,
				dialogClass : 'commonDialog',
				buttons: {
					"Yes, I'm sure": function() {
						var idToBeDeleted = $("#deleteId").val();
						var url = "<c:url value='/web/deleteConnectorConfig?bizsysId='/>" + ${command.id} + "&connectorConfigId=" + idToBeDeleted;
						window.location.href = url;
					},
					"No, I don't want": function() {
						$(this).dialog("close");
					}
				}
			});
		});
</script>
<div title="Add new connector config" id="newConnectorConfigDialog">
	<form:form method="post" action="addConnectorConfigure" id="newConnectorConfigform">
		<input type="hidden" name="bizsysid" value="${command.id}" id="bizsysid">
		<div style="font-size:12px;margin-bottom:10px">
			<span class="label" style="width:150px">Name:</span>
			<span><input type="text" name="connectorname" id="connectornamee"></span>
			<span>Name this configure</span>
		</div>
		<c:if test="${not empty connectorConfigLabelList}">
		<c:forEach items="${connectorConfigLabelList}" var="oneLabel" varStatus="currentStep">
		<div style="font-size:12px;margin-bottom:10px">
			<input type="hidden" name="connectorConfigureParaBean[${currentStep.count - 1}].key" value="${oneLabel.idName}" id="connectorConfigureParaBean[${currentStep.count - 1}].key">
			<span class="label" style="width:150px">${oneLabel.displayName}:</span>
			<span><input type="text" name="connectorConfigureParaBean[${currentStep.count - 1}].value" id="connectorConfigureParaBean[${currentStep.count - 1}].value"></span>
			<span><c:if test="${oneLabel.example != ''}">(e.g. ${oneLabel.example })</c:if></span>
		</div>
		</c:forEach>
		</c:if>
	</form:form>
	<br/>
</div>

<div id="deleteDialog" title="Delete Configuration">
	<h3 id="disablemessage">Please confirm to delete the Configuration '<span id="deleteName" style="color:RED"></span>'</h3>
	<input type="hidden" id="deleteId" name="deleteId"/>
	<br/>
</div>
<div class="homePage ui-tabs-panel ui-widget-content ui-corner-bottom">
	<div id="leftMenu">
		<%@include file="/WEB-INF/views/includes/bizsysAdminLeftNav.jsp"%>
	</div>
	<div id="rightContent">
		<%@include file="/WEB-INF/views/includes/messages.jsp"%>
		<h2>Connector configures of ${command.name}</h2>
		<div class="searchBlock">
				<button type="button"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						onclick="addNewSystem()" style="margin-top:5px">
						<span class="ui-button-text">Add new Connector Configure</span>
				</button>
				<br/><br/>
		</div>
		<div>
			<table class="generaltable" style="width:100%" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<th>Name</th>
						<c:forEach items="${connectorConfigLabelList}" var="oneLabel">
						<th>${oneLabel.displayName}</th>
						</c:forEach>						
						<th>Operation</th>
					</tr>
				</thead>
				<tbody>
				<c:if test="${not empty connectorConfigList}">
					<c:forEach items="${connectorConfigList}" var="oneConfig">
					<tr class="dataRow">
						<td>${oneConfig.connectorname}</td>
						<c:forEach items="${oneConfig.connectorConfigureParaBean}" var="oneConfigPara">
							<td>${oneConfigPara.value}</td>
						</c:forEach>
						
						<td>
							<a href="#" onclick="editConnection('${oneConfig.connectorId}')">Edit</a>&nbsp;&nbsp;
							<a href="#" onclick="deleteConfiguration('${oneConfig.connectorId}', '${oneConfig.connectorname}')">Delete</a>&nbsp;&nbsp;
						</td>
					</tr>
					</c:forEach>
				</c:if>
				</tbody>
			</table>
		</div>
		<div style="height:1px;width:740px;"></div>
	</div>
</div>

<%@include file="/WEB-INF/views/includes/adminfooter.jsp"%>